import 'package:healthy_station_flutter/generated/json/base/json_convert_content.dart';
import 'package:healthy_station_flutter/entity/diag_and_presciption_entity.dart';
import 'package:healthy_station_flutter/entity/pre_info_entity.dart';

import '../../entity/diag_info_entity.dart';
import '../../entity/fee_info_entity.dart';


DiagAndPresciptionEntity $DiagAndPresciptionEntityFromJson(
    Map<String, dynamic> json) {
  final DiagAndPresciptionEntity diagAndPresciptionEntity = DiagAndPresciptionEntity();
  final String? createTime = jsonConvert.convert<String>(json['createTime']);
  if (createTime != null) {
    diagAndPresciptionEntity.createTime = createTime;
  }
  final String? opcId = jsonConvert.convert<String>(json['opcId']);
  if (opcId != null) {
    diagAndPresciptionEntity.opcId = opcId;
  }
  final String? consultTime = jsonConvert.convert<String>(json['consultTime']);
  if (consultTime != null) {
    diagAndPresciptionEntity.consultTime = consultTime;
  }
  final String? clinicId = jsonConvert.convert<String>(json['clinicId']);
  if (clinicId != null) {
    diagAndPresciptionEntity.clinicId = clinicId;
  }
  final String? patName = jsonConvert.convert<String>(json['patName']);
  if (patName != null) {
    diagAndPresciptionEntity.patName = patName;
  }
  final String? cardType = jsonConvert.convert<String>(json['cardType']);
  if (cardType != null) {
    diagAndPresciptionEntity.cardType = cardType;
  }
  final String? cardData = jsonConvert.convert<String>(json['cardData']);
  if (cardData != null) {
    diagAndPresciptionEntity.cardData = cardData;
  }
  final String? idCard = jsonConvert.convert<String>(json['idCard']);
  if (idCard != null) {
    diagAndPresciptionEntity.idCard = idCard;
  }
  final String? patBirth = jsonConvert.convert<String>(json['patBirth']);
  if (patBirth != null) {
    diagAndPresciptionEntity.patBirth = patBirth;
  }
  final String? state = jsonConvert.convert<String>(json['state']);
  if (state != null) {
    diagAndPresciptionEntity.state = state;
  }
  final String? diagOpinion = jsonConvert.convert<String>(json['diagOpinion']);
  if (diagOpinion != null) {
    diagAndPresciptionEntity.diagOpinion = diagOpinion;
  }
  final List<String>? preIds = (json['preIds'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (preIds != null) {
    diagAndPresciptionEntity.preIds = preIds;
  }
  final List<PreInfoEntity>? preInfo = (json['preInfo'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<PreInfoEntity>(e) as PreInfoEntity)
      .toList();
  if (preInfo != null) {
    diagAndPresciptionEntity.preInfo = preInfo;
  }
  final List<FeeInfoEntity>? feeInfo = (json['feeInfo'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<FeeInfoEntity>(e) as FeeInfoEntity)
      .toList();
  if (feeInfo != null) {
    diagAndPresciptionEntity.feeInfo = feeInfo;
  }
  final List<DiagInfoEntity>? diagInfo = (json['diagInfo'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<DiagInfoEntity>(e) as DiagInfoEntity)
      .toList();
  if (diagInfo != null) {
    diagAndPresciptionEntity.diagInfo = diagInfo;
  }
  return diagAndPresciptionEntity;
}

Map<String, dynamic> $DiagAndPresciptionEntityToJson(
    DiagAndPresciptionEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['createTime'] = entity.createTime;
  data['opcId'] = entity.opcId;
  data['consultTime'] = entity.consultTime;
  data['clinicId'] = entity.clinicId;
  data['patName'] = entity.patName;
  data['cardType'] = entity.cardType;
  data['cardData'] = entity.cardData;
  data['idCard'] = entity.idCard;
  data['patBirth'] = entity.patBirth;
  data['state'] = entity.state;
  data['diagOpinion'] = entity.diagOpinion;
  data['preIds'] = entity.preIds;
  data['preInfo'] = entity.preInfo?.map((v) => v.toJson()).toList();
  data['feeInfo'] = entity.feeInfo?.map((v) => v.toJson()).toList();
  data['diagInfo'] = entity.diagInfo?.map((v) => v.toJson()).toList();
  return data;
}

extension DiagAndPresciptionEntityExtension on DiagAndPresciptionEntity {
  DiagAndPresciptionEntity copyWith({
    String? createTime,
    String? opcId,
    String? consultTime,
    String? clinicId,
    String? patName,
    String? cardType,
    String? cardData,
    String? idCard,
    String? patBirth,
    String? state,
    String? diagOpinion,
    List<String>? preIds,
    List<PreInfoEntity>? preInfo,
    List<FeeInfoEntity>? feeInfo,
    List<DiagInfoEntity>? diagInfo,
  }) {
    return DiagAndPresciptionEntity()
      ..createTime = createTime ?? this.createTime
      ..opcId = opcId ?? this.opcId
      ..consultTime = consultTime ?? this.consultTime
      ..clinicId = clinicId ?? this.clinicId
      ..patName = patName ?? this.patName
      ..cardType = cardType ?? this.cardType
      ..cardData = cardData ?? this.cardData
      ..idCard = idCard ?? this.idCard
      ..patBirth = patBirth ?? this.patBirth
      ..state = state ?? this.state
      ..diagOpinion = diagOpinion ?? this.diagOpinion
      ..preIds = preIds ?? this.preIds
      ..preInfo = preInfo ?? this.preInfo
      ..feeInfo = feeInfo ?? this.feeInfo
      ..diagInfo = diagInfo ?? this.diagInfo;
  }
}